//
//  DiscoverTableViewCell.m
//  Coco_Music
//
//  Created by 强哥 on 15/6/22.
//  Copyright (c) 2015年 寇广超. All rights reserved.
//

#import "DiscoverTableViewCell.h"
#import "UIImageView+WebCache.h"



@implementation DiscoverTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self creation];
    }
    return self;
}

-(void)dealloc
{
    [self.TitleImage release];
    [self.TitleLabel release];
    [self.labelDesc release];
    [self.ImageLine release];
    [self.discover release];
    [super dealloc];
}

//推荐界面详情
-(void)creation
{

    self.TitleImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"cm2_default_artist_banner-1"]];
    self.TitleImage.frame = CGRectMake(self.bounds.origin.x+10, self.bounds.origin.y+10, [UIScreen mainScreen].bounds.size.width/4.5, [UIScreen mainScreen].bounds.size.width/4.5);
    NSLog(@"%@",NSStringFromCGRect([UIScreen mainScreen].bounds));
    self.TitleImage.layer.masksToBounds = YES;
    self.TitleImage.layer.cornerRadius = 10;
    [self.contentView addSubview:self.TitleImage];
    [self.TitleImage release];
    
    self.TitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.TitleImage.frame.size.width+25, self.bounds.origin.y+15, self.bounds.size.width-self.TitleImage.frame.size.width-30, 30)];
    self.TitleLabel.font = [UIFont fontWithName:@"Menlo-Bold" size:18];
    [self.contentView addSubview:self.TitleLabel];
    [self.TitleLabel release];
    
    
    self.labelDesc = [[UILabel alloc]initWithFrame:CGRectMake(self.TitleLabel.frame.origin.x, self.TitleLabel.frame.origin.y+30, [UIScreen mainScreen].bounds.size.width-self.TitleImage.frame.size.width-40, 30)];
    self.labelDesc.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:self.labelDesc];
    self.labelDesc.numberOfLines = 0;
    [self.labelDesc release];
    
    self.ImageLine = [[UIImageView alloc]initWithFrame:CGRectMake(_TitleImage.frame.size.width+20, _TitleImage.frame.size.height+13, [UIScreen mainScreen].bounds.size.width-_TitleImage.frame.size.width-40, 1)];
    NSLog(@"%f",self.frame.size.height);
    _ImageLine.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.ImageLine];
    [self.ImageLine release];
    
}

-(void)setDiscover:(Discover *)discover
{
    if (_discover != discover) {
        [_discover release];
        _discover = [discover retain];
    }
    NSURL *url = [NSURL URLWithString:self.discover.CellPic_url];
    self.TitleLabel.text = self.discover.CellName;
    self.labelDesc.text = self.discover.CellDesc;
    [self.labelDesc sizeToFit];
    [self.TitleImage sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"cm2_default_artist_banner-1"]];
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
